import java.io.File;
import java.util.*;
/**
 * The class used to locate all the files in target directory
 *
 */
public class FileReader
{
	private List<File> listFile;

	public FileReader() { listFile = new ArrayList<File>(); }

	/**
	 * 
	 * @param directory the target directory to be read
	 */
	public void readFiles(String directory)
	{
		File folder = new File(directory);
		File[] listOfFiles = folder.listFiles();
		
		for (int i = 0 ; i < listOfFiles.length;i++)
		{
			if (listOfFiles[i].isFile())
			{
				listFile.add(listOfFiles[i]);
			}
			else
			{
				readFiles(listOfFiles[i].getName());
			}
		}
	}

	/**
	 * 
	 * @return the list of files contained in previously read directory
	 */
	public List<File> getFiles() { return listFile; }
}
